package 补充.输入输出操作.文件操作;

import java.io.*;

public class 为文添加行号 {

    public static void main(String[] args) throws IOException {
        FileReader fr = new FileReader("D:\\Learn\\javademo\\untitled\\src\\补充_偏\\输入输出操作\\read.txt");
        FileWriter fw = new FileWriter("D:\\Learn\\javademo\\untitled\\src\\补充_偏\\输入输出操作\\read2.txt");
        LineNumberReader lnr = new LineNumberReader(fr);
        lnr.setLineNumber(0);
        String str = null;
        while ((str=lnr.readLine())!=null){
            fw.write(lnr.getLineNumber()+str);
            fw.write("\r\n");
        }
        fr.close();
        fw.close();
    }
}
